var MenuItem = function(){
	this.name = "";
	this.label = "";
	this.path = "";
	this.parentId = "";
};
MenuItem.prototype.setItem = function(itemInfo){
	if(itemInfo.name){
		this.name = itemInfo.name;
	}
	if(itemInfo.label){
		this.label = itemInfo.label;
	}
	if(itemInfo.path){
		this.path = itemInfo.path;
	}
	if(itemInfo.name){
		this.parentId = itemInfo.parentId;
	}
};
MenuItem.prototype.getItem = function(){
	return this;
};
var items = new Array();
var xmlNode = "";
var PraseItem = function(){
	this.id = "menu";
	this.initMenu = this.readXML();
}
PraseItem.prototype.readXML = function(){
	xmlNode = document.getElementById(this.id);
	if (xmlNode != null) {
		var firstLevelNodes;
		if (browserType == browserType1) {
			firstLevelNodes = xmlNode.documentElement;
		} else {
			firstLevelNodes = xmlNode.getElementsByTagName("items")[0];
		}
		iterateXMLNodes("",firstLevelNodes,"menubar");
	}
}
function iterateXMLNodes(parentId,rootNode,id) {
	var childNodesArray = rootNode.childNodes;
	for (var i = 0; i < childNodesArray.length; i++) {
		var childNode3 = childNodesArray[i];
		if (browserType == browserType1 || childNode3.nodeName.charAt(0) != "#") {
			var itemInfo1 = {};
			var menuItem1 = new MenuItem();
			if(childNode3.getAttribute("name")){
				itemInfo1.name = childNode3.getAttribute("name");
			}
			if(childNode3.getAttribute("label")){
				itemInfo1.label = childNode3.getAttribute("label");
			}
			if(childNode3.getAttribute("path")){
				itemInfo1.path = childNode3.getAttribute("path");
			}
			menuItem1.setItem(itemInfo1);
			items.push(menuItem1.getItem());
		}
	}
	show(id);
};
function clean(){
	document.getElementById("menubar_two").className = "nav_s_display";
	document.getElementById("menubar_three").className = "nav_ss_display";
};
function clean3(){
	document.getElementById("menubar_three").className = "nav_ss_display";
};
function show(id){
	clean();
	var TableElement = document.getElementById(id);
	TableElement.innerText = "";
	var TrElement = document.createElement("P");
	for(var i = 0; i < items.length; i++){
		var path = items[i].getItem().path;
		var label = items[i].getItem().label;
		var name = items[i].getItem().name;
		var TdElement = document.createElement("SPAN");
		TdElement.onclick = function(){
			var allnode = this.parentNode.childNodes;
			for(var i = 0; i < allnode.length; i++){
				allnode[i].className = "";
			}
			this.className = "now_td";
		};
		TrElement.appendChild(TdElement);
		var link = document.createElement("A");
		if(path == ""){
			link.setAttribute("href","javascript:showMenuItem2(\"" + name + "\",\"menubar_two\")");
			link.onclick = clean;
		}else{
			link.setAttribute("href",path);
			link.onclick = clean;
			link.setAttribute("target","main");
		}
		var linkName = document.createTextNode(label);
		link.appendChild(linkName);
		TdElement.appendChild(link);
	}
	TableElement.appendChild(TrElement);
}
function showMenuItem2(name,id){
	items.length = 0;
	if (xmlNode != null) {
		var firstLevelNodes;
		if (browserType == browserType1) {
			rootNode = xmlNode.documentElement;
		} else {
			rootNode = xmlNode.getElementsByTagName("items")[0];
		}
		var childNodesArray = rootNode.childNodes;
		for (var i = 0; i < childNodesArray.length; i++) {
			var childNode3 = childNodesArray[i];
			if (browserType == browserType1 || childNode3.nodeName.charAt(0) != "#") {
				if(childNode3.getAttribute("name")==name){
					for(var j = 0; j<childNode3.childNodes.length;j++){
						var childNode4 = childNode3.childNodes[j];
						if (browserType == browserType1 || childNode4.nodeName.charAt(0) != "#" ) {//this add if code
							var itemInfo1 = {};
							var menuItem1 = new MenuItem();
							if(childNode4.getAttribute("name")){
								itemInfo1.name = childNode4.getAttribute("name");
							}
							if(childNode4.getAttribute("label")){
								itemInfo1.label = childNode4.getAttribute("label");
							}
							if(childNode4.getAttribute("path")){
								itemInfo1.path = childNode4.getAttribute("path");
							}
							menuItem1.setItem(itemInfo1);
							items.push(menuItem1.getItem());
						}
					}
				}
			}
		}
		show2(id);
	}
}
function show2(id){
	var TableElement = document.getElementById(id);
	TableElement.innerText = "";
	var TrElement = document.createElement("P");
	for(var i = 0; i < items.length; i++){
		var path = items[i].getItem().path;
		var label = items[i].getItem().label;
		var name = items[i].getItem().name;
		var TdElement = document.createElement("SPAN");
		TdElement.onclick = function(){
			var allnode = this.parentNode.childNodes;
			for(var i = 0; i < allnode.length; i++){
				allnode[i].className = "";
			}
			this.className = "now_td2";
		};
		TrElement.appendChild(TdElement);
		var link = document.createElement("A");
		if(path == ""){
			link.setAttribute("href","javascript:showMenuItem3(\"" + name + "\",\"menubar_three\")");
			link.onclick = clean3;
		}else{
			link.setAttribute("href",path);
			link.onclick = clean3;
			link.setAttribute("target","main");
		}
		var linkName = document.createTextNode(label);
		link.appendChild(linkName);
		TableElement.className = "nav_s";
		TdElement.appendChild(link);
	}
	TableElement.appendChild(TrElement);
}
function showMenuItem3(name,id){
	items.length = 0;
	if (xmlNode != null) {
		var firstLevelNodes;
		if (browserType == browserType1) {
			rootNode = xmlNode.documentElement;
		} else {
			rootNode = xmlNode.getElementsByTagName("items")[0];
		}
		var childNodesArray = rootNode.childNodes;
		for (var i = 0; i < childNodesArray.length; i++) {
			var childNode3 = childNodesArray[i];
			if (browserType == browserType1 || childNode3.nodeName.charAt(0) != "#") {
				for(var j = 0; j<childNode3.childNodes.length;j++){
					var childNode4 = childNode3.childNodes[j];
					if (browserType == browserType1 || childNode4.nodeName.charAt(0) != "#" ) {//this add if code
						if(childNode4.getAttribute("name")==name){
							
							for(var k = 0; k<childNode4.childNodes.length;k++){
								var childNode5 = childNode4.childNodes[k];
								if (browserType == browserType1 || childNode5.nodeName.charAt(0) != "#" ) {//this add if code
									var itemInfo1 = {};
									var menuItem1 = new MenuItem();
									if(childNode5.getAttribute("name")){
										itemInfo1.name = childNode5.getAttribute("name");
									}
									if(childNode5.getAttribute("label")){
										itemInfo1.label = childNode5.getAttribute("label");
									}
									if(childNode5.getAttribute("path")){
										itemInfo1.path = childNode5.getAttribute("path");
									}
									menuItem1.setItem(itemInfo1);
									items.push(menuItem1.getItem());
								}
							}
						}
					}
				}
			}
		}
		show3(id);
	}
}
function show3(id){
	var TableElement = document.getElementById(id);
	TableElement.innerText = "";
	var TrElement = document.createElement("P");
	for(var i = 0; i < items.length; i++){
		var path = items[i].getItem().path;
		var label = items[i].getItem().label;
		var name = items[i].getItem().name;
		var TdElement = document.createElement("SPAN");
		TdElement.onclick = function(){
			var allnode = this.parentNode.childNodes;
			for(var i = 0; i < allnode.length; i++){
				allnode[i].className = "";
			}
			this.className = "now_td3";
		};
		TrElement.appendChild(TdElement);
		var link = document.createElement("A");
		//link.onclick = clean;
		if(path!=""){
			link.setAttribute("href",path);
			link.setAttribute("target","main");
		}
		var linkName = document.createTextNode(label);
		link.appendChild(linkName);
		TdElement.appendChild(link);
		TableElement.className = "nav_ss";
	}
	TableElement.appendChild(TrElement);
}
